//
//  CollectTableViewCell.m
//  BTRIP
//
//  Created by Rain on 15/11/17.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "CollectTableViewCell.h"
#import "CollectTravelModel.h"
#import "FoodShopCollectModel.h"
#import <UIImageView+WebCache.h>
#import <SDWebImageManager.h>

@implementation CollectTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.image_url = [[UIImageView alloc] init];
        [self.contentView addSubview:self.image_url];
        [self.image_url release];
        
        self.name = [[UILabel alloc] init];
        self.name.font = [UIFont systemFontOfSize:24 weight:1.6];
        self.name.textColor = [UIColor whiteColor];
        self.name.shadowColor = [UIColor grayColor];
        [self.contentView addSubview:self.name];
        [self.name release];
        
    }
    return self;
}

- (void)setCollectTravelModel:(CollectTravelModel *)collectTravelModel {
    
    if (![_collectTravelModel.name isEqualToString:@""]) {
        if (_collectTravelModel != collectTravelModel) {
            [_collectTravelModel release];
            _collectTravelModel = [collectTravelModel retain];
        }
        self.name.text = _collectTravelModel.name;
        [self.image_url sd_setImageWithURL:[NSURL URLWithString:_collectTravelModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
    }
    
}

- (void)setFoodShopModel:(FoodShopCollectModel *)foodShopModel {
    if (![_foodShopModel.name isEqualToString:@""]) {
        if (_foodShopModel != foodShopModel) {
            [_foodShopModel release];
            _foodShopModel = [foodShopModel retain];
        }
        self.name.text = _foodShopModel.name;
        [self.image_url sd_setImageWithURL:[NSURL URLWithString:_foodShopModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
    }
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.name.frame = CGRectMake(20 * SWIDTH, self.frame.size.height - 60 * SWIDTH, self.frame.size.width - 40 * SWIDTH, 40 * SWIDTH);
    self.image_url.frame = CGRectMake(10 * SWIDTH, 10 * SWIDTH, self.frame.size.width - 20 * SWIDTH, self.frame.size.height - 20 * SWIDTH);
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
